singleApp.controller('editCtrl', ['$http', '$scope', function ($http, $scope) {
    $scope.vm = {
        pass: "",
        repass: "",
    };



    $scope.submit = function () {
        if ($scope.vm.pass == undefined || $scope.vm.pass == "") {
            layer.msg("请输入密码 !");
            return;
        }
        if ($scope.vm.repass == undefined || $scope.vm.repass == "") {
            layer.msg("请输入密码 !");
            return;
        }

        if ($scope.vm.pass != $scope.vm.repass) {
            layer.msg("两次密码输入不一致，请重新输入!");
            return;
        }

        api_url = window.singleConfig.rootUrl + 'api/user/AuthService/editPost';
        layer.load(2);
        $http({
            method: 'POST',
            url: api_url,
            data: $.param($scope.vm),
            headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
        })
            .then(function (result) {
                var data = result.data;
                if (data.code == "success") {
                    layer.closeAll();
                    layer.msg("修改成功!");
                    setTimeout(function () {
                        location.href = window.singleConfig.rootUrl + "user/profile";
                    }, 500);
                }
                else {
                    layer.closeAll();
                    layer.msg(data.message);
                }
            }, function (data) {
                layer.closeAll();
                layer.msg("修改失败!");
            });



    };
}]);